home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 June / PCpro_2005_06.ISO / files / opensource / amc / amc_install.exe / {app} / Scripts / Allocine (FR).ifs < prev    next >
Encoding:
Text File  |  2005-03-12  |  43.2 KB  |  1,330 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=ScorEpioN
  8. Title=AllocinΘ
  9. Description=DonnΘes allocine.fr, Affiche allocine.fr ou amazon.fr
  10. Site=http://www.allocine.fr
  11. Language=FR
  12. Version=27 du 07/03/2005
  13. Requires=3.5.0
  14. Comments=Version rΘΘcrite par ScorEpioN pour remplacer l'ancienne version faite par Antoine Potten et Soltan
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19. Type de Lancement=1|1|0=Cherche le meilleur rΘsultat sans confirmation|1=Demande le titre avant de lancer le script|2=Ne demande pas le titre avant de lancer le script
  20. Format du Titre=3|3|0=Titre en minuscule|1=Titre en majuscule|2=PremiΦre lettre du titre en majuscule|3=PremiΦre lettre de chaque mot du titre en majuscule
  21. Recherche sur le titre=0|0|0=Traduit|1=Original
  22. Choix Image=1|1|0=Pas d'affiche|1=Petite affiche allocinΘ|2=Grande affiche allocinΘ|3=Grande affiche amazon.fr
  23. Acteurs=2|2|0=Ne prend pas la liste des acteurs|1=Prend les noms des acteurs de la page principale|2=Prend la liste complΦte des acteurs ainsi que leur r⌠le et le nom du producteur
  24. Secrets de tournage=2|2|0=Ne prend pas les secrets de tournage|1=Prend les scenes de tournage de la page principale|2=Prend la liste complΦte des scenes de tournage
  25. Note=2|2|0=Ne prend pas les notes ni dans le champs commentaire ni dans le champs rating|1=Prend les notes dans le champs rating avec une preference pour la note des spectateurs|2=Prend les notes dans le champs rating et dans le champs commentaire
  26. Critiques Presse=1|0|0=Aucune critique|1=Critiques presse de la page principale|2=Critiques presse complΦtes
  27. Disposition=1|1|0=Synopsis et Secrets de tournage dans le champs description|1=Les informations sont dispatchΘes
  28.  
  29. ***************************************************)
  30.  
  31. program Allocine_FR;
  32.  
  33. var
  34.   MovieName, Adresse, AdressePlus, La_liste, LaGrandeImage, LaPremiereGrandeImage, Reponse, AdresseSuivant, AdressePrecedent, LePremierFilmAdresse, strTemp, aucunAmazon : string;
  35.   numPage, numPageG, numPageR, grandeTaille, premiereTaille, compteur, premiereExecution, numTemp, i : Integer;
  36.   listeResultat: TStringList;
  37.  
  38. //------------------------------------------------------------------------------
  39. // VERIFIER LA VERSION DU SCRIPT
  40. //------------------------------------------------------------------------------
  41.  
  42. procedure verifVersion();
  43. var
  44.    Line, NewVersion : String;
  45.    BeginPos, EndPos : Integer;
  46. begin
  47.   Line := GetPage('http://forum.antp.be/phpbb2/viewtopic.php?t=1453');
  48.   BeginPos := pos('TELECHARGER LE SCRIPT ALLOCINE v', Line);
  49.   delete(Line,1, BeginPos+31);
  50.   EndPos := pos('du', Line);
  51.   NewVersion := copy(Line, 1, EndPos - 2);
  52.   if (ShowConfirmation('La derniΦre version est la '+NewVersion+'. Cliquer sur ''''OUI'''' pour la tΘlΘcharger.') = True) then
  53.   begin
  54.     Launch('iexplore.exe','http://www.ifrance.com/ricoland/AlloCine%20(FR).ifs');
  55.   end else
  56.     exit;
  57. end;
  58.  
  59. //------------------------------------------------------------------------------
  60. // MET LE TITRE AU BON FORMAT
  61. //------------------------------------------------------------------------------
  62.  
  63. function formatTitre(titre : String; option : Integer) : string;
  64. begin
  65.   if (option = 0) then
  66.   begin
  67.      titre := AnsiLowerCase(titre);
  68.   end else if (option = 1) then
  69.   begin
  70.      titre := AnsiUpperCase(titre);
  71.   end else if (option = 2) then
  72.   begin
  73.      titre := AnsiUpFirstLetter(titre);
  74.   end else if (option = 3) then
  75.   begin
  76.      titre := AnsiMixedCase(titre,' -');
  77.   end;
  78.   result := titre;
  79. end;
  80.  
  81. //------------------------------------------------------------------------------
  82. // CALCUL DE LA NOTE
  83. //------------------------------------------------------------------------------
  84.  
  85. function calculNote(Value : String) : string;
  86. begin
  87.   if (Value = '0') then
  88.   begin
  89.     Value := '0';
  90.   end else
  91.   if (Value = '1') then
  92.   begin
  93.     Value := '2';
  94.   end else
  95.   if (Value = '2') then
  96.   begin
  97.     Value := '4';
  98.   end else
  99.   if (Value = '3') then
  100.   begin
  101.     Value := '6';
  102.   end else
  103.   if (Value = '4') then
  104.   begin
  105.     Value := '8';
  106.   end;
  107.   result := Value;
  108. end;
  109.  
  110. //------------------------------------------------------------------------------
  111. // ANALYSE DE LA PAGE DE RECHERCHES
  112. //------------------------------------------------------------------------------
  113.  
  114. procedure AnalyzePage(Address: string);
  115. var
  116.   LineNr: Integer;
  117.   Line: string;
  118.   BeginPos, EndPos : Integer;
  119. begin
  120.   Line := GetPage(Address);
  121.  
  122.   if pos('Pas de rΘsultats',Line) <> 0 then
  123.   begin
  124.   if (GetOption('Type de Lancement') = 1) or (GetOption('Type de Lancement') = 2) then
  125.   begin
  126.     showmessage('Aucun film trouvΘ pour : '+MovieName);
  127.     exit;
  128.   end else
  129.   begin
  130.     SetField(fieldURL, '[Batch Allo-CinΘ] Aucun RΘsultat pour : '+MovieName);
  131.     exit;
  132.   end;
  133.   end;
  134.  
  135.   if pos('Recherche :', Line) = 0 then
  136.   begin
  137.     Adresse := Address;
  138.     AnalyzeMoviePage();
  139.   end else
  140.   begin
  141.     PickTreeClear;
  142.     if pos('<h3><b>Films <h4>', Line) > 0 then
  143.     begin
  144.       EndPos := length(Line);
  145.       Line := copy(Line,1,EndPos);
  146.       BeginPos := Pos('<td colspan="2" valign="top">', Line);
  147.       Delete(Line, 1, BeginPos);
  148.       EndPos := length(Line);
  149.       Line := copy(Line,1,EndPos);
  150.       PickTreeAdd('Films trouvΘs pour ' + MovieName + ' :', '');
  151.       AddMoviesTitles(Line);
  152.       PickTreeAdd(' ', '');
  153.       PickTreeAdd('Verifier si vous avez la derniΦre version', 'version');
  154.       PickTreeAdd('Pour me contacter', 'contact');
  155.     end;
  156.     if compteur = 1 then
  157.     begin
  158.       compteur := 0;
  159.       AnalyzeMoviePage();
  160.       exit;
  161.     end else if (GetOption('Type de Lancement') = 1) or (GetOption('Type de Lancement') = 2) then
  162.     begin
  163.       begin
  164.         if PickTreeExec(Address) then
  165.         begin
  166.           Adresse := Address;
  167.           if (Adresse = 'version') then
  168.           begin
  169.             verifVersion();
  170.           end else if (Address = 'contact') then
  171.           begin
  172.             Launch('iexplore.exe','http://forum.antp.be/phpbb2/viewtopic.php?t=1453');
  173.           end else
  174.           if (Adresse = AdressePlus) then
  175.           begin
  176.             numPageR := numPageR+1;
  177.             AnalyzePage(AdressePlus);
  178.           end else
  179.           if (Adresse = AdressePrecedent) then
  180.           begin
  181.             numPageR := numPageR-1;
  182.             AnalyzePage(AdressePrecedent);
  183.           end else
  184.           if (Adresse = AdresseSuivant) then
  185.           begin
  186.             numPageR := numPageR+1;
  187.             AnalyzePage(AdresseSuivant);
  188.           end else
  189.           begin
  190.             AnalyzeMoviePage();
  191.           end;
  192.         end;
  193.       end;
  194.     end else
  195.     begin
  196.       if (GetOption('Type de Lancement') = 0) then
  197.       begin
  198.         Adresse := trouveResultat(MovieName);
  199.         sleep(500);
  200.         if Adresse <> '' then
  201.           AnalyzeMoviePage();
  202.       end ;
  203.     end;
  204.   end;
  205. end;
  206.  
  207. //------------------------------------------------------------------------------
  208. // TROUVE LE BON RESULTAT
  209. //------------------------------------------------------------------------------
  210.  
  211. function trouveResultat(title : String) : String;
  212. var
  213.    oK, couple, titre, adresse : String;
  214. begin
  215.    for i:=0 to listeResultat.Count-1 do
  216.    begin
  217.      couple := listeResultat.GetString(i);
  218.      titre := copy(couple,0,pos('|',couple)-1);
  219.      adresse := copy(couple,pos('|',couple)+1,length(couple)-1);
  220.      oK := compareTitle(title,titre);
  221.      if oK = 'OK' then
  222.      begin
  223.        result := adresse;
  224.        exit;
  225.      end;
  226.    end;
  227.    if oK = 'KO' then
  228.      result := '';
  229.    listeResultat.Free;
  230.  
  231. end;
  232.  
  233. //------------------------------------------------------------------------------
  234. // FONCTION METS LE CHAMPS COMMENTAIRE A LA SUITE DU CHAMPS DESCRIPTION
  235. //------------------------------------------------------------------------------
  236. procedure moveComments();
  237. begin
  238.    SetField(fieldDescription,GetField(fieldDescription)+GetField(fieldComments));
  239.    SetField(fieldComments,'');
  240. end;
  241.  
  242. //------------------------------------------------------------------------------
  243. // ANALYSE DE LA PAGE DU FILM
  244. //------------------------------------------------------------------------------
  245.  
  246. procedure AnalyzeMoviePage();
  247. var
  248.   Line, Value, AdresseCasting, AdresseSecret, AdressePresse, AdresseGalerie, aucun, Avertissement: string;
  249.   LineNr, IntValue: Integer;
  250.   BeginPos, EndPos, FinPos: Integer;
  251. begin
  252. //charge la page
  253.   Line := GetPage(Adresse);
  254.   Avertissement := '';
  255. // URL
  256.   if CanSetField(fieldURL) then
  257.   begin
  258.     if (GetOption('Type de Lancement') = 0) then
  259.     begin
  260.       SetField(fieldURL, '[Batch Allo-CinΘ] Ancien titre : '+MovieName);
  261.     end else
  262.     begin
  263.       SetField(fieldURL, URLEncode(Adresse));
  264.     end;
  265.  
  266.   end;
  267. //translated title
  268.   if CanSetField(fieldTranslatedTitle) then
  269.   begin
  270.   BeginPos := pos('<title>', Line);
  271.   delete(Line,1, BeginPos+6);
  272.   EndPos := pos('</title>', Line);
  273.   Value := copy(Line, 1, EndPos - 1);
  274.   SetField(fieldTranslatedTitle, formatTitre(value,GetOption('Format du Titre')));
  275.   end;
  276. // Picture
  277.   if CanSetPicture then
  278.   begin
  279.     if (GetOption('Choix Image') = 3) then
  280.     begin
  281.       imageAmazon(Value);
  282.       if (aucunAmazon = 'aucune image') then
  283.       begin
  284.         if (pos('Toute la Galerie Photos', Line) > 0) then
  285.         begin
  286.           aucun := Adresse;
  287.            delete(aucun,1,pos('.fr', aucun)+3);
  288.           AdresseGalerie := 'http://www.allocine.fr/'+copy(aucun, 1, pos('/', aucun))+'galerie_gen_cfilm=';
  289.           delete(aucun,1,pos('=', aucun));
  290.           AdresseGalerie := AdresseGalerie +aucun;
  291.           grandeTaille := 0;
  292.           numPageG := 1;
  293.           galerieImage(AdresseGalerie);
  294.         end else
  295.         begin
  296.           BeginPos := pos('<td valign="top" style="padding:0 10 5 0">', Line);
  297.             delete(Line,1, BeginPos);
  298.           BeginPos := pos('width="100%"><img src=', Line);
  299.           delete(Line,1, BeginPos+22);
  300.             EndPos := pos('" border', Line);
  301.             Value := copy(Line, 1, EndPos - 1);
  302.             GetPicture(Value);
  303.         end;
  304.       end;
  305.     end
  306.     else
  307.     if (GetOption('Choix Image') = 1) then
  308.     begin
  309.       BeginPos := pos('<td valign="top" style="padding:0 10 5 0">', Line);
  310.       delete(Line,1, BeginPos);
  311.       BeginPos := pos('width="100%"><img src=', Line);
  312.       delete(Line,1, BeginPos+22);
  313.       EndPos := pos('" border', Line);
  314.       Value := copy(Line, 1, EndPos - 1);
  315.       GetPicture(Value);
  316.     end
  317.     else
  318.     if (GetOption('Choix Image') = 2) then
  319.     begin
  320.    // Adresse Galerie de photo
  321.       if pos('Toute la Galerie Photos', Line) > 0 then
  322.       begin
  323.         aucun := Adresse;
  324.         delete(aucun,1,pos('.fr', aucun)+3);
  325.         AdresseGalerie := 'http://www.allocine.fr/'+copy(aucun, 1, pos('/', aucun))+'galerie_gen_cfilm=';
  326.         delete(aucun,1,pos('=', aucun));
  327.         AdresseGalerie := AdresseGalerie +aucun;
  328.         grandeTaille := 0;
  329.         numPageG := 1;
  330.         galerieImage(AdresseGalerie);
  331.       end else
  332.       begin
  333.         BeginPos := pos('<td valign="top" style="padding:0 10 5 0">', Line);
  334.         delete(Line,1, BeginPos);
  335.         BeginPos := pos('width="100%"><img src=', Line);
  336.         delete(Line,1, BeginPos+22);
  337.         EndPos := pos('" border', Line);
  338.         Value := copy(Line, 1, EndPos - 1);
  339.         GetPicture(Value);
  340.       end;
  341.     end;
  342.   end; // CanSetPicture
  343. // Director
  344.     if CanSetField(fieldDirector) then
  345.     begin
  346.     if pos('<h4>RΘalisΘ par ', Line) > 0 then
  347.     begin
  348.       Delete(Line, 1, pos('<h4>RΘalisΘ par ', Line) + 15);
  349.       EndPos := pos('</a></h4>', Line);
  350.       Value := copy(Line, 1, EndPos - 1);
  351.       HTMLRemoveTags(Value);
  352.       HTMLDecode(Value);
  353.       SetField(fieldDirector, Value);
  354.     end;
  355.     end;
  356. // Adresse casting complet
  357.     if pos('Voir tout le casting', Line) > 0 then
  358.     begin
  359.       Delete(Line, 1, pos('<h4><a href=', Line) + 12);
  360.       EndPos := pos('.html"', Line);
  361.       AdresseCasting := 'http://www.allocine.fr'+copy(Line, 1, EndPos + 4);
  362.     end;
  363. // Actors
  364.     if (GetOption('Acteurs') = 1) then
  365.     begin
  366.     if pos('<h4>Avec ', Line) > 0 then
  367.     begin
  368.       Delete(Line, 1, pos('<h4>Avec ', Line) + 8);
  369.       EndPos := pos('</h4><br />', Line);
  370.       Value := copy(Line, 1, EndPos - 1);
  371.       HTMLRemoveTags(Value);
  372.       HTMLDecode(Value);
  373.       SetField(fieldActors, Trim(Value));
  374.     end;
  375.     end;
  376. //Country
  377.     if CanSetField(fieldCountry) then
  378.     begin
  379.     if pos('<h4>Film ', Line) > 0 then
  380.     begin
  381.       Delete(Line, 1, pos('<h4>Film ', Line) + 8);
  382.       EndPos := pos('</h4>', Line);
  383.       Value := copy(Line, 1, EndPos - 2);
  384.       Value := AnsiUpFirstLetter(Value);
  385.       Value := AnsiMixedCase(Value,' -');
  386.       Value := transformCountry(Value);
  387.       SetField(fieldCountry, Value);
  388.     end;
  389.     end;
  390. // Category
  391.     if CanSetField(fieldCategory) then
  392.     begin
  393.     BeginPos := pos('<h4>Genre : ', Line);
  394.     if (BeginPos > 0) then
  395.     begin
  396.       Delete(Line, 1, pos('<h4>Genre : ', Line) + 11);
  397.       EndPos := pos('</h4>', Line);
  398.       Value := copy(Line, 1, EndPos - 1);
  399.       Value := AnsiUpFirstLetter(Value);
  400.       SetField(fieldCategory, Value);
  401.     end;
  402.     end;
  403. // Length
  404.     if CanSetField(fieldLength) then
  405.     begin
  406.     if pos('DurΘe : ', Line) > 0 then
  407.     begin
  408.       Delete(Line, 1, pos('DurΘe : ', Line) + 7);
  409.       IntValue := StrToInt(copy(Line, 1, 1), 0) * 60;
  410.       if pos('min.', Line) > 0 then
  411.       begin
  412.         delete(Line,1,pos('h', Line) + 1);
  413.         Value := copy(Line, 1, pos('min.',Line)-1);
  414.         Value := StringReplace(Value, ' ', '');
  415.         IntValue := IntValue + StrToInt(Value, 0);
  416.       end;
  417.       SetField(fieldLength, IntToStr(IntValue));
  418.     end;
  419.     end;
  420. // Year
  421.     if CanSetField(fieldYear) then
  422.     begin
  423.     if pos('<h4>AnnΘe de production : ', Line) > 0 then
  424.     begin
  425.       Delete(Line, 1, pos('<h4>AnnΘe de production : ', Line)+24);
  426.       EndPos := pos('</h4>', Line);
  427.       Value := copy(Line, 1, EndPos -1);
  428.       SetField(fieldYear, Value);
  429.     end;
  430.     end;
  431. // Avertissement
  432.    BeginPos := pos('Interdit', Line);
  433.    if (BeginPos > 0) then
  434.    begin
  435.      Delete(Line, 1, BeginPos-1);
  436.      EndPos := pos('</h4>', Line);
  437.      Avertissement := copy(Line, 1, EndPos - 1)+#13#10#13#10;
  438.      SetField(fieldComments, Trim(Avertissement));
  439.    end;
  440. // Original Title
  441.   if CanSetField(fieldOriginalTitle) then
  442.   begin
  443.   BeginPos := pos('<h4>Titre original : ', Line);
  444.   if BeginPos <> 0 then
  445.   begin
  446.     delete(Line,1, BeginPos+20);
  447.     EndPos := pos('</h4>', Line);
  448.     Value := copy(Line, 1, EndPos - 1);
  449.     //Value := AnsiUpFirstLetter(Value);
  450.     //Value := AnsiMixedCase(Value,' -');
  451.     HTMLRemoveTags(Value);
  452.     SetField(fieldOriginalTitle, formatTitre(value,GetOption('Format du Titre')));    
  453.   end else
  454.   begin
  455.     SetField(fieldOriginalTitle, GetField(fieldTranslatedTitle));
  456.   end;
  457.   end;
  458. // Productor + More actors
  459.     if (GetOption('Acteurs') = 2) then
  460.     begin
  461.     castingComplet(AdresseCasting);
  462.     end;
  463. // Rating
  464.     if (pos('<h4>Critiques :', Line) > 0) and (GetOption('Note ')<> 0)then
  465.     begin
  466.       Delete(Line, 1, pos('<h4>Critiques :', Line) + 14);
  467.       if pos('Presse', Line) > 0 then
  468.       begin
  469.       EndPos := pos('.gif', Line);
  470.       Delete(Line, 1, EndPos-2);
  471.       Value := copy(Line, 1, 1);
  472.       Delete(Line, 1, EndPos+3);
  473.       if GetOption('Note') = 2 then
  474.       begin
  475.         Avertissement := Avertissement + 'Note de la presse : ' + Value + '/4 ';
  476.       end;
  477.       SetField(fieldRating,calculNote(Value));
  478.       end;
  479.       if pos('Spectateurs', Line) > 0 then
  480.       begin
  481.       EndPos := pos('.gif', Line);
  482.       Delete(Line, 1, EndPos-2);
  483.       Value := copy(Line, 1, 1);
  484.       Delete(Line, 1, EndPos+3);
  485.       if GetOption('Note') = 2 then
  486.       begin
  487.         Avertissement := Avertissement + 'Note des spectateurs : ' + Value + '/4';
  488.       end;
  489.       SetField(fieldRating,calculNote(Value));
  490.       end;
  491.       if GetOption('Note') = 2 then
  492.       begin
  493.         Avertissement := Avertissement + #13#10#13#10;
  494.         SetField(fieldComments, Avertissement);
  495.       end;
  496.     end;
  497. // Description
  498.   if CanSetField(fieldDescription) then
  499.   begin
  500.   if pos('<h3><b>Synopsis', Line) > 0 then
  501.   begin
  502.    Delete(Line, 1, pos('<h3><b>Synopsis', Line));
  503.    Delete(Line, 1, pos('<h4>', Line) + 3);
  504.    EndPos := pos('</h4>', Line);
  505.    Value := copy(Line, 1, EndPos - 1);
  506.    HTMLRemoveTags(Value);
  507.    HTMLDecode(Value);
  508.    SetField(fieldDescription, Trim(Value));
  509.   end;
  510.   end;
  511. // Adresse tous les secrets de tournage
  512.     if pos('Tous les secrets de tournage', Line) > 0 then
  513.     begin
  514.       aucun := Adresse;
  515.       delete(aucun,1,pos('.fr', aucun)+3);
  516.       AdresseSecret := 'http://www.allocine.fr/'+copy(aucun, 1, pos('/', aucun))+'anecdote_gen_cfilm=';
  517.       delete(aucun,1,pos('=', aucun));
  518.       AdresseSecret := AdresseSecret +aucun;
  519.     end;
  520. // Commments
  521.   if (pos('<h3><b>Secrets de tournage', Line) > 0) and (GetOption('Secrets de tournage') = 1) then
  522.   begin
  523.    Delete(Line, 1, pos('<h3><b>Secrets de tournage', Line));
  524.    Delete(Line, 1, pos('</table>', Line)+7);
  525.    Value := Avertissement+'Secrets de tournage :'+#13#10#13#10;
  526.    BeginPos := pos('<h4><b>', Line);
  527.    repeat
  528.      Delete(Line, 1, BeginPos+6);
  529.      EndPos := pos('</b></h4>', Line);
  530.      aucun := Trim(copy(Line, 1, EndPos - 1));
  531.      aucun := StringReplace(aucun, #13#10, '');
  532.      Value := Value + aucun +' :'+#13#10;
  533.      BeginPos := pos('<h4>', Line);
  534.      Delete(Line, 1, BeginPos-1);
  535.      FinPos := FinPos - BeginPos+1;
  536.      EndPos := pos('</h4>', Line);
  537.      aucun := Trim(copy(Line, 1, EndPos - 1));
  538.      aucun := StringReplace(aucun, #13#10, '');
  539.      Value := Value + aucun +#13#10#13#10;
  540.      Delete(Line, 1, EndPos-1);
  541.      FinPos := FinPos - EndPos+1;
  542.      BeginPos := pos('<h4><b>', Line);
  543.      delete(Line, 1, BeginPos-8);
  544.      FinPos := FinPos - BeginPos+8;
  545.      aucun := copy(Line, 1, 5);
  546.      BeginPos := pos('<h4><b>', Line);
  547.      FinPos := pos('</table>',Line);
  548.      if (BeginPos > FinPos) then
  549.      BeginPos := 0;
  550.    until ((BeginPos = 0) or (aucun = 'link1'));
  551.    HTMLRemoveTags(Value);
  552.    HTMLDecode(Value);
  553.    SetField(fieldComments, Trim(Value));
  554.   end else
  555.   if (pos('<h3><b>Secrets de tournage', Line) > 0) and (GetOption('Secrets de tournage') = 2) then
  556.   begin
  557.    La_liste := Avertissement+'Secrets de tournage :'+#13#10#13#10;
  558.    numPage := 1;
  559.    secretComplet(AdresseSecret);
  560.   end;
  561.  
  562. // Pour avoir le synopsis et les secrets de tournage dans le champs descriptions
  563.   if (GetOption('Disposition') = 0) then
  564.   begin
  565.     moveComments();
  566.   end;
  567.  
  568. // Critiques presse
  569.   if ((GetOption('Critiques Presse') <> 0) and (pos('<h3><b>Critiques Presse</b></h3>', Line) > 0)) then
  570.   begin
  571.     Value := GetField(fieldComments)+'Critiques Presse :'+#13#10#13#10;
  572.     if (GetOption('Critiques Presse') =1) then
  573.     begin
  574.       repeat
  575.       BeginPos := pos('<td valign="top"><h4><b>', Line);
  576.       delete(Line, 1, BeginPos-1);
  577.       // Journal et nom du critique
  578.       EndPos := pos('<img', Line);
  579.       aucun := copy(Line, 1, EndPos);
  580.       HTMLRemoveTags(aucun);
  581.       aucun := StringReplace(aucun, ' ', ' ');
  582.       Value := Value + aucun;
  583.       // Note
  584.       EndPos := pos('.gif', Line);
  585.       Delete(Line, 1, EndPos-2);
  586.       aucun := copy(Line, 1, 1);
  587.       Value := Value+' - Note : '+aucun+ '/4 ';
  588.       // la critique
  589.       BeginPos := pos('<div align="justify"><h4>', Line);
  590.       delete(Line, 1, BeginPos-1);
  591.       EndPos := pos('</h4></div>', Line);
  592.       aucun := copy(Line, 1, EndPos);
  593.       HTMLRemoveTags(aucun);
  594.       aucun := StringReplace(aucun, '        ', '');
  595.       aucun := trim(aucun);
  596.       Value := Value+aucun+#13#10;
  597.       until (pos('<td valign="top"><h4><b>', Line) = 0);
  598.       SetField(fieldComments, Trim(Value));
  599.     end else if (GetOption('Critiques Presse') = 2) then
  600.     begin
  601.       La_liste := Value;
  602.       numPage := 1;
  603.       // L'url des critiques presse
  604.       if (pos('Toutes les critiques Presse...', Line) > 0) then
  605.       begin
  606.         aucun := Adresse;
  607.         delete(aucun,1,pos('.fr', aucun)+3);
  608.         AdressePresse := 'http://www.allocine.fr/'+copy(aucun, 1, pos('/', aucun))+'revuedepresse_gen_cfilm=';
  609.         delete(aucun,1,pos('=', aucun));
  610.         AdressePresse := AdressePresse +aucun;
  611.       end;
  612.       critiquesPresseComplet(adressePresse);
  613.     end;
  614.   end;
  615.  
  616.  
  617. end;
  618.  
  619. //------------------------------------------------------------------------------
  620. // ANALYSE DE LA PAGE CRITIQUES PRESSE
  621. //------------------------------------------------------------------------------
  622.  
  623. procedure critiquesPresseComplet(pageCritiques: string);
  624. var
  625.   Line, LineSuivant, Value, pageSuivante, aucun :string;
  626.   BeginPos, EndPos : Integer;
  627. begin
  628. // pour eviter les time-out
  629.   sleep(1500);
  630. // charge la page
  631.   Line := GetPage(pageCritiques);
  632.   LineSuivant := Line;
  633.   numPage := numPage + 1;
  634.   if Pos('<b>Critiques Presse</b>', Line) > 0 then
  635.   begin
  636. // Les critiques presses
  637.   BeginPos := Pos('<b>Critiques Presse</b>', Line);
  638.   Delete(Line, 1, BeginPos-1);
  639.   repeat
  640.       BeginPos := pos('<td valign="top"><h4><b>', Line);
  641.       delete(Line, 1, BeginPos-1);
  642.       // Journal et nom du critique
  643.       EndPos := pos('<img', Line);
  644.       aucun := copy(Line, 1, EndPos);
  645.       HTMLRemoveTags(aucun);
  646.       aucun := StringReplace(aucun, ' ', ' ');
  647.       Value := aucun;
  648.       // Note
  649.       EndPos := pos('.gif', Line);
  650.       Delete(Line, 1, EndPos-2);
  651.       aucun := copy(Line, 1, 1);
  652.       Value := Value+' - Note : '+aucun+ '/4 ';
  653.       // la critique
  654.       BeginPos := pos('<div align="justify"><h4>', Line);
  655.       delete(Line, 1, BeginPos-1);
  656.       EndPos := pos('</h4></div>', Line);
  657.       aucun := copy(Line, 1, EndPos);
  658.       HTMLRemoveTags(aucun);
  659.       aucun := StringReplace(aucun, '        ', '');
  660.       aucun := trim(aucun);
  661.       aucun := copy(aucun, 1, pos('Voir aussi : La revue de presse de',aucun)-1);
  662.       Value := Value+aucun+#13#10;
  663.       // La critique dans la liste
  664.       La_liste := La_liste + Value;
  665.   until (pos('<td valign="top"><h4><b>', Line) = 0);
  666.   SetField(fieldComments, La_liste);
  667. // si on a plusieurs pages
  668.   pageSuivante := pageCritiques;
  669.   delete(pageSuivante,1,pos('.fr', pageSuivante)+2);
  670.   pageSuivante := copy(pageSuivante, 1, pos('.html', pageSuivante)-1);
  671.   if pos('page',pageSuivante) = 0 then
  672.   begin
  673.     pageSuivante := pageSuivante+'&page='+IntToStr(numPage)+'.html';
  674.   end else
  675.   begin
  676.     pageSuivante := copy(pageSuivante, 1, pos('&page=', pageSuivante)-1)+'&page='+IntToStr(numPage)+'.html';
  677.   end;
  678.   BeginPos := pos(pageSuivante,LineSuivant);
  679.   if BeginPos <> 0 then
  680.   begin
  681.     pageSuivante := 'http://www.allocine.fr'+pageSuivante;
  682.     critiquesPresseComplet(pageSuivante);
  683.   end;
  684.   end;
  685. end;
  686.  
  687.  
  688. //------------------------------------------------------------------------------
  689. // ANALYSE DE LA PAGE CASTING
  690. //------------------------------------------------------------------------------
  691.  
  692. procedure castingComplet(pageCasting: string);
  693. var
  694.   Line, Role, Acteur, couple, liste, Producteur :string;
  695.   BeginPos, EndPos, OtherPos : Integer;
  696. begin
  697. //pour eviter les time-out
  698.   sleep(1500);
  699. //charge la page
  700.   Line := GetPage(pageCasting);
  701.   if (GetOption('Acteurs') = 2) then
  702.   begin
  703.   if Pos('<b>Acteur(s)</b>', Line) > 0 then
  704.   begin
  705. //liste des acteurs
  706.   BeginPos := Pos('<b>Acteur(s)</b>', Line);
  707.   Delete(Line, 1, BeginPos);
  708.   BeginPos := Pos('<h5>', Line);
  709.   liste := '';
  710.   repeat
  711. // le role
  712.   delete(Line,1,BeginPos-1);
  713.   EndPos := Pos('</h5>', Line);
  714.   Role := copy(Line,1,EndPos);
  715.   HTMLRemoveTags(Role);
  716.   delete(Line,1,EndPos);
  717. // le nom de l'acteur
  718.   BeginPos := Pos('<h4><a href', Line);
  719.   delete(Line,1,BeginPos+3);
  720.   BeginPos := Pos('<h4>', Line);
  721.   delete(Line,1,BeginPos-1);
  722.   EndPos := Pos('</h4>', Line);
  723.   Acteur := copy(Line,1,EndPos);
  724.   HTMLRemoveTags(Acteur);
  725.   delete(Line,1,EndPos);
  726. // couple acteur (r⌠le)
  727.   if (Role <> '') then
  728.   begin
  729.     couple := Acteur +' ('+Role+'), ';
  730.   end else
  731.   begin
  732.     couple := Acteur +', ';
  733.   end;
  734. // ajout du couple dans la liste
  735.   if (Role <> 'ScΘnariste') then
  736.   begin
  737. // pour un nouvel ajout
  738.    BeginPos := Pos('<h5>', Line);
  739.    OtherPos := Pos('</table>',Line);
  740.    liste := liste + couple;
  741.    if (BeginPos > OtherPos) then
  742.    BeginPos := 0;
  743.   end else
  744.   begin
  745.    BeginPos := 0;
  746.   end;
  747.   until (BeginPos = 0);
  748.   EndPos := length(liste);
  749.   liste := copy(liste,1,EndPos-2)+'.';
  750.   SetField(fieldActors, liste);
  751.   end;
  752. // le producteur
  753.   if Pos('<h5>Producteur', Line) > 0 then
  754.   begin
  755.     BeginPos := Pos('<h5>Producteur', Line);
  756.     Delete(Line, 1, BeginPos);
  757.     BeginPos := Pos('<h4><a href', Line);
  758.     delete(Line,1,BeginPos+3);
  759.     BeginPos := Pos('<h4>', Line);
  760.     delete(Line,1,BeginPos+3);
  761.     EndPos := Pos('</h4>', Line);
  762.     Producteur := copy(Line,1,EndPos-1);
  763.     SetField(fieldProducer, Producteur);
  764.   end;
  765.   end;
  766. end;
  767.  
  768. //------------------------------------------------------------------------------
  769. // ANALYSE DE LA PAGE SECRETS DE TOURNAGE
  770. //------------------------------------------------------------------------------
  771.  
  772. procedure secretComplet(pageSecret: string);
  773. var
  774.   Line, LineSuivant, Titre, Texte, couple, pageSuivante :string;
  775.   BeginPos, EndPos : Integer;
  776. begin
  777. //pour eviter les time-out
  778.   sleep(1500);
  779. //charge la page
  780.   Line := GetPage(pageSecret);
  781.   LineSuivant := Line;
  782.   numPage := numPage + 1;
  783.   if Pos('Secrets de tournage</h2>', Line) > 0 then
  784.   begin
  785. //liste des secrets
  786.   BeginPos := Pos('Secrets de tournage</h2>', Line);
  787.   Delete(Line, 1, BeginPos);
  788.   BeginPos := Pos('<h4><b>', Line);
  789.   repeat
  790. // le titre
  791.      Delete(Line, 1, BeginPos+6);
  792.      EndPos := pos('</b></h4>', Line);
  793.      Titre := Trim(copy(Line, 1, EndPos - 1));
  794.      BeginPos := pos('<h4>', Line);
  795.      HTMLRemoveTags(Titre);
  796.      Titre := StringReplace(Titre, #13#10, '');
  797. // le texte
  798.      Delete(Line, 1, BeginPos-1);
  799.      EndPos := pos('</h4>', Line);
  800.      Texte := Trim(copy(Line, 1, EndPos - 1));
  801.      HTMLRemoveTags(Texte);
  802.      Texte := StringReplace(Texte, #13#10, '');
  803. // le couple titre : texte
  804.      couple := Titre+' :'+#13#10+Texte+#13#10#13#10;
  805.      Delete(Line, 1, EndPos-1);
  806.      if (Titre <> 'Toutes les offres spΘciales') then
  807.      begin
  808. // ajout du couple dans la liste
  809.        La_liste := La_liste + couple;
  810. // pour un nouvel ajout
  811.        BeginPos := pos('<h4><b>', Line);
  812.        EndPos := pos('</table>',Line);
  813.        if (BeginPos > EndPos) then
  814.        BeginPos := 0;
  815.      end else
  816.      begin
  817.        BeginPos := 0;
  818.      end;
  819.   until (BeginPos = 0);
  820.   SetField(fieldComments, La_liste);
  821. // si on a plusieurs pages
  822.   pageSuivante := pageSecret;
  823.   delete(pageSuivante,1,pos('.fr', pageSuivante)+2);
  824.   pageSuivante := copy(pageSuivante, 1, pos('.html', pageSuivante)-1);
  825.   if pos('page',pageSuivante) = 0 then
  826.   begin
  827.     pageSuivante := pageSuivante+'&page='+IntToStr(numPage)+'.html';
  828.   end else
  829.   begin
  830.     pageSuivante := copy(pageSuivante, 1, pos('&page=', pageSuivante)-1)+'&page='+IntToStr(numPage)+'.html';
  831.   end;
  832.   BeginPos := pos(pageSuivante,LineSuivant);
  833.   if BeginPos <> 0 then
  834.   begin
  835.     pageSuivante := 'http://www.allocine.fr'+pageSuivante;
  836.     secretComplet(pageSuivante);
  837.   end;
  838.   end;
  839. end;
  840.  
  841. //------------------------------------------------------------------------------
  842. // ANALYSE DE LA PAGE GALERIE
  843. //------------------------------------------------------------------------------
  844.  
  845. procedure galerieImage(pageGalerie: string);
  846. var
  847.   Line, Value, LineSuivant, pageSuivante :string;
  848.   BeginPos, EndPos, taille : Integer;
  849. begin
  850. //pour eviter les time-out
  851.   sleep(1500);
  852. //charge la page
  853.   Line := GetPage(pageGalerie);
  854.   LineSuivant := Line;
  855.   numPageG := numPageG + 1 ;
  856.   BeginPos := pos('<td  align="center" colspan="2">', Line);
  857.   delete(Line,1, BeginPos);
  858.   BeginPos := pos('<img src="', Line);
  859.   delete(Line,1, BeginPos+9);
  860.   EndPos := pos('" border', Line);
  861.   Value := copy(Line, 1, EndPos - 1);
  862.   delete(Line,1, EndPos);
  863.   BeginPos := pos('alt="', Line);
  864.   delete(Line,1, BeginPos+4);
  865.   EndPos := pos('Ko"', Line);
  866.   taille := StrToInt(Trim(copy(Line, 1, EndPos - 1)),0);
  867.   grandeTaille := taille;
  868.   LaGrandeImage := Value;
  869. (*  if numPageG = 2 then
  870.   begin
  871.     LaPremiereGrandeImage := Value;
  872.     premiereTaille := taille;
  873.   end;
  874. // si on a plusieurs pages
  875.   pageSuivante := pageGalerie;
  876.   delete(pageSuivante,1,pos('.fr', pageSuivante)+2);
  877.   pageSuivante := copy(pageSuivante, 1, pos('.html', pageSuivante)-1);
  878.   if pos('page',pageSuivante) = 0 then
  879.   begin
  880.     pageSuivante := pageSuivante+'&page='+IntToStr(numPageG)+'.html';
  881.   end else
  882.   begin
  883.     pageSuivante := copy(pageSuivante, 1, pos('&page=', pageSuivante)-1)+'&page='+IntToStr(numPageG)+'.html';
  884.   end;
  885.   BeginPos := pos(pageSuivante,LineSuivant);
  886.   if BeginPos <> 0 then
  887.   begin
  888.     pageSuivante := 'http://www.allocine.fr'+pageSuivante;
  889.     galerieImage(pageSuivante);
  890.   end;
  891.   if (premiereTaille > grandeTaille) then
  892.   begin
  893.     GetPicture(LaPremiereGrandeImage, False);
  894.   end else
  895.   begin *)
  896.     GetPicture(LaGrandeImage);
  897. (*  end; *)
  898. end;
  899.  
  900. //------------------------------------------------------------------------------
  901. // AJOUTE UN COUPLE FILM / ADRESSE A LA LISTE DE RESULTAT
  902. //------------------------------------------------------------------------------
  903.  
  904. procedure AddMoviesTitles(var Line: string);
  905. var
  906.   MovieTitle, MovieAddress, aucun: string;
  907.   StartPos, EndPos : Integer;
  908. begin
  909.  
  910. //compte les rΘsultats
  911.   compteur := 0;
  912.   listeResultat := TStringList.Create;
  913.  
  914.   repeat
  915.     StartPos := pos('<h4><a href=', Line);
  916.     if (StartPos > 0) and (StartPos < pos('<h3><b>Rechercher :', Line)) then
  917.     begin
  918.       Delete(Line, 1, StartPos + 12);
  919.       EndPos := pos('.html"', Line);
  920.       MovieAddress := copy(Line, 1, EndPos+4);
  921.       StartPos := pos('>', Line)+1;
  922.       MovieTitle := copy(Line, StartPos, pos('</h4>', Line) - StartPos);
  923.       MovieTitle := StringReplace(MovieTitle, ' ', ' ');
  924.       HTMLRemoveTags(MovieTitle);
  925.       delete(Line,1,pos('</h4>',Line)-1);
  926.       aucun := copy(Line, 1, pos('</td>',Line)-1);
  927.       aucun := StringReplace(aucun, ' ', ' ');
  928.       aucun := StringReplace(aucun, #13#10, '');
  929.       aucun := StringReplace(aucun, '    ', '');
  930.       HTMLRemoveTags(aucun);
  931.       adresse := 'http://www.allocine.fr' + MovieAddress;
  932. // Pour le mode batch le titre doit Ωtre "propre"
  933.       listeResultat.Add(MovieTitle+'|'+adresse);
  934. // si on a des informations complΘmentaires
  935.       if (aucun <> '') then
  936.       begin
  937.         MovieTitle := MovieTitle +' '+aucun;
  938.       end;
  939.       PickTreeAdd(MovieTitle, adresse);
  940.       (*if (compteur = 0) then
  941.       begin
  942.         LePremierFilmAdresse := adresse;
  943.       end;*)
  944.       compteur := compteur+1;
  945.     end else StartPos := 0;
  946.   until (StartPos < 1);
  947.  
  948. // si on a plus de rΘsultats
  949.   StartPos := pos('Plus de films',Line);
  950.   if StartPos <> 0 then
  951.   begin
  952.     AdressePlus := 'http://www.allocine.fr/recherche/?motcle='+UrlEncode(MovieName)+'&rub=1&page='+IntToStr(numPageR);
  953.     PickTreeAdd('Plus de rΘsultats',AdressePlus);
  954.   end;
  955.   numTemp := numPageR-1;
  956.   strTemp := IntToStr(numTemp);
  957.   if pos('<a href="/recherche/?motcle='+MovieName+'&rub=1&page='+strTemp,Line) <> 0 then
  958.   begin
  959.     AdressePrecedent := 'http://www.allocine.fr/recherche/?motcle='+UrlEncode(MovieName)+'&rub=1&page='+strTemp;
  960.     PickTreeAdd('Films prΘcΘdents',AdressePrecedent);
  961.   end;
  962.   numTemp := numPageR+1;
  963.   strTemp := IntToStr(numTemp);
  964.   if pos('<a href="/recherche/?motcle='+MovieName+'&rub=1&page='+strTemp,Line) <> 0 then
  965.   begin
  966.     AdresseSuivant := 'http://www.allocine.fr/recherche/?motcle='+UrlEncode(MovieName)+'&rub=1&page='+strTemp;
  967.     PickTreeAdd('Films suivants',AdresseSuivant);    
  968.   end;
  969.  
  970. end;
  971.  
  972. //------------------------------------------------------------------------------
  973. // RECUPERE GRANDE IMAGE AMAZON.FR
  974. //------------------------------------------------------------------------------
  975.  
  976. procedure imageAmazon(title : String);
  977. var
  978.   adresseRecherche, Line : String;
  979.   StartPos: Integer;
  980. begin
  981.   PickTreeClear;
  982.   adresseRecherche := 'http://www.amazon.fr/exec/obidos/search-handle-url/index=dvd-fr&field-keywords='+UrlEncode(title);
  983.   Line := GetPage(adresseRecherche);
  984.   if pos('satisfaisante pour votre recherche sur', Line) > 0 then
  985.   begin
  986.     exit;
  987.   end else
  988.   if (pos('Sur ce DVD', Line) > 0)  or (pos('Amazon.fr : DVD:', Line) > 0) then
  989.   begin
  990.       importAmazon(Line);
  991.   end else
  992.   if pos('résultats au total pour', Line) > 0 then
  993.   begin
  994.       StartPos := pos('résultats au total pour', Line);
  995.       delete(Line, 1, StartPos);
  996.       recupAmazon(Line, title);
  997.   end;
  998. end;
  999.  
  1000. //------------------------------------------------------------------------------
  1001. // SUPPRIME LES ACCENTS
  1002. //------------------------------------------------------------------------------
  1003.  
  1004. function supprimeAccents(NomFilm : String) : String;
  1005. begin
  1006.      NomFilm := StringReplace(NomFilm, 'Θ', 'e');
  1007.      NomFilm := StringReplace(NomFilm, 'Φ', 'e');
  1008.      NomFilm := StringReplace(NomFilm, 'α', 'a');
  1009.      NomFilm := StringReplace(NomFilm, 'τ', 'c');
  1010.      NomFilm := StringReplace(NomFilm, '∙', 'u');
  1011.      NomFilm := StringReplace(NomFilm, 'δ', 'e');
  1012.      NomFilm := StringReplace(NomFilm, 'Ω', 'e');
  1013.      NomFilm := StringReplace(NomFilm, '⌠', 'o');
  1014.      delete(NomFilm, pos(' - ',NomFilm), length(NomFilm));
  1015.      if (pos(', ',NomFilm) > 0) then
  1016.         delete(NomFilm, 1, pos(', ',NomFilm)+1);
  1017.      if (pos('(',NomFilm) > 0) then
  1018.         delete(NomFilm, pos('(',NomFilm), length(NomFilm));
  1019.      if (pos(':',NomFilm) > 0) then
  1020.         delete(NomFilm, pos(':',NomFilm), length(NomFilm));
  1021.      result := trim(NomFilm);
  1022. end;
  1023.  
  1024. //------------------------------------------------------------------------------
  1025. // IMPORTE L'IMAGE AMAZON
  1026. //------------------------------------------------------------------------------
  1027.  
  1028. procedure recupAmazon(Line, title : String);
  1029. begin
  1030.    if compareTitle(title,recupTitle(Line)) = 'OK' then
  1031.    begin
  1032.      importAmazon(Line);
  1033.    end else
  1034.    begin
  1035.      trouveTitle(Line,title);
  1036.    end;
  1037. end;
  1038.  
  1039.  
  1040. //------------------------------------------------------------------------------
  1041. // IMPORTE L'IMAGE AMAZON
  1042. //------------------------------------------------------------------------------
  1043.  
  1044. procedure importAmazon(Line : String);
  1045. var
  1046.    ImageAddress : String;
  1047.    StartPos: Integer;
  1048. begin
  1049.      StartPos := pos('http://images-eu.amazon.com/images/P/', Line);
  1050.      delete(Line, 1, StartPos-1);
  1051.      ImageAddress := copy(Line, 0, pos('"', Line) - 1);
  1052.      ImageAddress := StringReplace(ImageAddress, 'THUMBZZZ', 'LZZZZZZZ');
  1053.      Sleep(500);
  1054.      GetPicture(ImageAddress);
  1055. end;
  1056.  
  1057. //------------------------------------------------------------------------------
  1058. // RECUPERE LE TITRE
  1059. //------------------------------------------------------------------------------
  1060.  
  1061. function recupTitle(Line : String) : String;
  1062. var
  1063.    title : String;
  1064.    StartPos: Integer;
  1065. begin
  1066.      StartPos := pos('http://images-eu.amazon.com/images/P/', Line);
  1067.      delete(Line, 1, StartPos-1);
  1068.      StartPos := pos('<b>', Line);
  1069.      delete(Line, 1, StartPos-1);
  1070.      title := copy(Line, 1, pos('</b></a>', Line)-1);
  1071.      HTMLRemoveTags(title);
  1072.      title := StringReplace(title, #13#10, '');
  1073.      result := title;
  1074. end;
  1075.  
  1076. //------------------------------------------------------------------------------
  1077. // VERIFIE LE RESULTAT AMAZON
  1078. //------------------------------------------------------------------------------
  1079.  
  1080. function compareTitle(titleAllo, title : String) : String;
  1081. begin
  1082.      title := supprimeAccents(trim(AnsiLowerCase(title)));
  1083.      titleAllo := supprimeAccents(trim(AnsiLowerCase(titleAllo)));
  1084.      if (title = titleAllo) then
  1085.      begin
  1086.        result := 'OK';
  1087.      end else
  1088.      begin
  1089.        result := 'KO';
  1090.      end;
  1091. end;
  1092.  
  1093. //------------------------------------------------------------------------------
  1094. // TROUVE LE BON TITRE SI LE PREMIER N'EST PAS LE BON
  1095. //------------------------------------------------------------------------------
  1096.  
  1097. procedure trouveTitle(Line, title : String);
  1098. var
  1099.    StartPos: Integer;
  1100.    oK : String;
  1101. begin
  1102.    StartPos := pos('<a href=/exec/obidos/ASIN/', Line);
  1103.    repeat
  1104.      delete(Line, 1, StartPos+length('<a href=/exec/obidos/ASIN/'));
  1105.      oK := compareTitle(title,recupTitle(Line));
  1106.      if oK = 'OK' then
  1107.        importAmazon(Line);
  1108.      StartPos := pos('http://images-eu.amazon.com/images/P/', Line);
  1109.      delete(Line, 1, StartPos-1);
  1110.      StartPos := pos('<b>', Line);
  1111.      delete(Line, 1, StartPos-1);
  1112.      StartPos := pos('<a href=/exec/obidos/ASIN/', Line);
  1113.   until (StartPos = 0) or  (oK = 'OK');
  1114.   if oK = 'KO' then
  1115.      aucunAmazon := 'aucune image';
  1116. end;
  1117.  
  1118. //------------------------------------------------------------------------------
  1119. // NETTOIE LE TITRE DU FICHIER POUR AVOIR LE TITRE DE FILM
  1120. //------------------------------------------------------------------------------
  1121.  
  1122. function cleanTitle(title : String) : string;
  1123. var
  1124.   i,j, fin : Integer;
  1125.   temp : String;
  1126.  
  1127. begin
  1128.   title := AnsiUpperCase(title);
  1129.  
  1130.   if title <> '' then
  1131.   begin
  1132. // Nettoie les tags fichiers, merci Atmosfear pour les tags
  1133.   i:=pos('.DVD',title);
  1134.   if i <> 0 then
  1135.   begin
  1136.     title := copy(title,1,i-1);
  1137.   end;
  1138.   i:=pos('.DIVX',title);
  1139.   if i <> 0 then
  1140.   begin
  1141.     title := copy(title,1,i-1);
  1142.   end;
  1143.   i:=pos('.FREN',title);
  1144.   if i <> 0 then
  1145.   begin
  1146.     title := copy(title,1,i-1);
  1147.   end;
  1148.   i:=pos('.GERM',title);
  1149.   if i <> 0 then
  1150.   begin
  1151.     title := copy(title,1,i-1);
  1152.   end;
  1153.   i:=pos('.INT',title);
  1154.   if i <> 0 then
  1155.   begin
  1156.     title := copy(title,1,i-1);
  1157.   end;
  1158.   i:=pos('.LIM',title);
  1159.   if i <> 0 then
  1160.   begin
  1161.     title := copy(title,1,i-1);
  1162.   end;
  1163.   i:=pos('.PROP',title);
  1164.   if i <> 0 then
  1165.   begin
  1166.     title := copy(title,1,i-1);
  1167.   end;
  1168.   i:=pos('.REPACK',title);
  1169.   if i <> 0 then
  1170.   begin
  1171.     title := copy(title,1,i-1);
  1172.   end;
  1173.   i:=pos('.SUBB',title);
  1174.   if i <> 0 then
  1175.   begin
  1176.     title := copy(title,1,i-1);
  1177.   end;
  1178.   i:=pos('.UNSUB',title);
  1179.   if i <> 0 then
  1180.   begin
  1181.     title := copy(title,1,i-1);
  1182.   end;
  1183.   i:=pos('.WS',title);
  1184.   if i <> 0 then
  1185.   begin
  1186.     title := copy(title,1,i-1);
  1187.   end;
  1188.   i:=pos('.XVID',title);
  1189.   if i <> 0 then
  1190.   begin
  1191.     title := copy(title,1,i-1);
  1192.   end;
  1193.   i:=pos('.AC3',title);
  1194.   if i <> 0 then
  1195.   begin
  1196.     title := copy(title,1,i-1);
  1197.   end;
  1198.   i:=pos('.UNRAT',title);
  1199.   if i <> 0 then
  1200.   begin
  1201.     title := copy(title,1,i-1);
  1202.   end;
  1203.  
  1204.    title := StringReplace(title, '.', ' ');
  1205.    title := StringReplace(title, ',', ' ');
  1206.    title := StringReplace(title, ':', '');
  1207.    title := StringReplace(title, '-', '');
  1208.    title := StringReplace(title, '  ', ' ');
  1209.  
  1210.    i := 0;
  1211. // Nettoie les tags de team
  1212.    if (pos('(',title) <> 0) then
  1213.    begin
  1214.      i := pos('(',title);
  1215.      temp := copy(title,0,i-1);
  1216.      j := pos(')',title);
  1217.      fin := Length(title);
  1218.      title := temp + copy(title,j+1,fin);
  1219.    end;
  1220.  
  1221.    if (pos('[',title) <> 0) then
  1222.    begin
  1223.      i := pos('[',title);
  1224.      temp := copy(title,1,i-1);
  1225.      j := pos(']',title);
  1226.      fin := Length(title);
  1227.      title := temp + copy(title,j+1,fin);
  1228.    end;
  1229.  
  1230.    title := AnsiLowerCase(title);
  1231.    title := AnsiUpFirstLetter(title);
  1232.    title := AnsiMixedCase(title,' -');
  1233.   end;
  1234.    result := title;
  1235. end;
  1236.  
  1237. //------------------------------------------------------------------------------
  1238. // TRANSFORME NATIONALITE EN PAYS
  1239. //------------------------------------------------------------------------------
  1240.  
  1241. function transformCountry(country : String) : string;
  1242. begin
  1243.   country := AnsiLowerCase(country);
  1244.   country := StringReplace(country, 'amΘricain', 'USA');
  1245.   country := StringReplace(country, 'japonais', 'Japon');
  1246.   country := StringReplace(country, 'franτais', 'France');
  1247.   country := StringReplace(country, 'tha∩landais', 'Tha∩lande');
  1248.   country := StringReplace(country, 'sud-corΘen', 'CorΘe');
  1249.   country := StringReplace(country, 'espagnol', 'Espagne');
  1250.   country := StringReplace(country, 'italien', 'Italie');
  1251.   country := StringReplace(country, 'britannique', 'Grande-Bretagne');
  1252.   country := StringReplace(country, 'hong-kongais', 'Hong-Kong');
  1253.   country := StringReplace(country, 'nΘo-zΘlandais', 'Nouvelle-ZΘlande');
  1254.   country := StringReplace(country, 'chinois', 'Chine');
  1255.   country := StringReplace(country, 'ta∩wanais', 'Ta∩wan');
  1256.   country := StringReplace(country, 'mexicain', 'Mexique');
  1257.   country := StringReplace(country, 'brΘsilien', 'BrΘsil');
  1258.   country := StringReplace(country, 'allemand', 'Allemagne');
  1259.   country := StringReplace(country, 'belge', 'Belgique');
  1260.   country := StringReplace(country, 'suΘdois', 'SuΦde');
  1261.   country := StringReplace(country, 'danois', 'Danemark');
  1262.   country := StringReplace(country, 'finlandais', 'Finlande');
  1263.   country := StringReplace(country, 'islandais', 'Islande');
  1264.   country := StringReplace(country, 'nΘerlandais', 'Pays-Bas');
  1265.   country := StringReplace(country, 'portugais', 'Portugal');
  1266.   country := StringReplace(country, 'canadien', 'Canada');
  1267.   country := StringReplace(country, 'australien', 'Australie');
  1268.   country := StringReplace(country, 'russe', 'Russie');
  1269.   country := StringReplace(country, 'tchΦque', 'RΘpublique TchΦque');
  1270.   country := StringReplace(country, 'chilien', 'Chili');
  1271.   country := StringReplace(country, 'hongrois', 'Hongrie');
  1272.   country := StringReplace(country, 'argentin', 'Argentine');
  1273.   country := StringReplace(country, 'roumain', 'Roumanie');
  1274.   country := StringReplace(country, '', '');
  1275.   result := country;
  1276. end;
  1277.  
  1278. //------------------------------------------------------------------------------
  1279. // PROGRAMME PRINCIPAL
  1280. //------------------------------------------------------------------------------
  1281.  
  1282. begin
  1283.   if CheckVersion(3,5,0) then
  1284.   begin
  1285.     numPageR := 1;
  1286.     if (GetOption('Recherche sur le titre') = 0) then
  1287.     begin
  1288.       MovieName := GetField(fieldTranslatedTitle);
  1289.       if MovieName = '' then
  1290.         MovieName := GetField(fieldOriginalTitle);
  1291.     end else
  1292.     if (GetOption('Recherche sur le titre') = 1) then
  1293.     begin
  1294.       MovieName := GetField(fieldOriginalTitle);
  1295.       if MovieName = '' then
  1296.         MovieName := GetField(fieldTranslatedTitle);
  1297.     end;
  1298.     MovieName := cleanTitle(MovieName);
  1299.     if (GetOption('Type de Lancement') = 1) then
  1300.     begin
  1301.       if Input('AllocinΘ.fr by ScorEpioN', 'Entrez le titre du film :', MovieName) then
  1302.       begin
  1303.         if Pos('allocine.', MovieName) > 0 then
  1304.         begin
  1305.           adresse := MovieName;
  1306.           AnalyzeMoviePage();
  1307.         end else
  1308.         begin
  1309.           AnalyzePage('http://www.allocine.fr/recherche/?motcle='+UrlEncode(MovieName)+'&rub=1');
  1310.         end;
  1311.       end;
  1312.     end else
  1313.     begin
  1314.       if (premiereExecution = 0) then
  1315.       begin
  1316.           premiereExecution := -1;
  1317.           if (ShowConfirmation('Vous allez executer le script sans confirmation, cliquer sur ''''OUI'''' pour continuer') = True) then
  1318.           begin
  1319.             AnalyzePage('http://www.allocine.fr/recherche/?motcle='+UrlEncode(MovieName)+'&rub=1');
  1320.           end else
  1321.             exit;
  1322.       end else
  1323.       begin
  1324.           AnalyzePage('http://www.allocine.fr/recherche/?motcle='+UrlEncode(MovieName)+'&rub=1');
  1325.       end;
  1326.     end;
  1327.   end else
  1328.     ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
  1329. end.
  1330.